﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>

<!-- Shim to make HTML5 elements usable in older Internet Explorer versions -->
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<!--[if lt IE 9]>
    <script type="text/javascript" src="../../Scripts/excanvas/excanvas.js"></script>
<![endif]-->
<script type="text/javascript" src="../../Scripts/spinners/spinners.js"></script>
<script type="text/javascript" src="../../Scripts/lightview/lightview.js"></script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="../../Scripts/vendor/jquery.ui.widget.js"></script>
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="http://blueimp.github.com/JavaScript-Templates/tmpl.min.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"></script>
<!-- Bootstrap JS and Bootstrap Image Gallery are not required, but included for the demo -->
<script src="http://blueimp.github.com/cdn/js/bootstrap.min.js"></script>
<script src="http://blueimp.github.com/Bootstrap-Image-Gallery/js/bootstrap-image-gallery.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="../../Scripts/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="../../Scripts/jquery.fileupload.js"></script>
<!-- The File Upload image processing plugin -->
<script src="../../Scripts/jquery.fileupload-ip.js"></script>
<!-- The File Upload user interface plugin -->
<script src="../../Scripts/jquery.fileupload-ui.js"></script>
<!-- The localization script -->
<script src="../../Scripts/locale.js"></script>
<!-- The main application script -->
<script src="../../Scripts/Album.js"></script>
<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->
<!--[if gte IE 8]><script src="../../Scripts/cors/jquery.xdr-transport.js"></script><![endif]-->
<script type="text/javascript">
    $('#fileupload').fileupload(
    {
        xhrFields: {
            withCredentials: true
        }
    });
</script>

<!-- The file upload form used as target for the file upload widget -->
<form id="fileupload" action="<%= Url.Action("Upload", "Profile") %>" method="POST" enctype="multipart/form-data">
    <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
    <div class="row fileupload-buttonbar">
        <div class="span7">
            <!-- The fileinput-button span is used to style the file input field as button -->
            <span class="btn btn-success fileinput-button">
                <i class="icon-plus icon-white"></i>
                <span>Add files...</span>
                <input type="file" name="files[]" multiple>
            </span>
            <button type="submit" class="btn btn-primary start">
                <i class="icon-upload icon-white"></i>
                <span>Start upload</span>
            </button>
            <button type="reset" class="btn btn-warning cancel">
                <i class="icon-ban-circle icon-white"></i>
                <span>Cancel upload</span>
            </button>
            <button type="button" class="btn btn-danger delete">
                <i class="icon-trash icon-white"></i>
                <span>Delete</span>
            </button>
            <input type="checkbox" class="toggle">
        </div>
    </div>
    <!-- The loading indicator is shown during image processing -->
    <div class="fileupload-loading"></div>
    <!-- The table listing the files available for upload/download -->
    <div class="files"></div>
    <div class="textRight">
        <input class="continueButton" type="submit" value="Continue" />
    </div>
    <input type="hidden" name="AlbumId" value="<%= ViewData["AlbumId"] %>" />
</form>
<!-- The template to display files available for upload -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <div class="template-upload fade upPhotoContainer">
        <span class="preview">
            <span class="fade"></span>
        </span>
        </br>
        <span class="name">{%=file.name%}</span>
        <span class="size">
            <span>{%=o.formatFileSize(file.size)%}</span>
        </span>
        </br>
        {% if (file.error) { %}
            <span class="error">
                <span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}
            </span>
        {% } else if (o.files.valid && !i) { %}
            <span>
                <div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
            </span>
            <span class="start">{% if (!o.options.autoUpload) { %}
                <button class="btn btn-primary">
                    <i class="icon-upload icon-white"></i>
                    <span>{%=locale.fileupload.start%}</span>
                </button>
            {% } %}</span>
        {% } else { %}
        {% } %}
        <span class="cancel">{% if (!i) { %}
            <button class="btn btn-warning">
                <i class="icon-ban-circle icon-white"></i>
                <span>{%=locale.fileupload.cancel%}</span>
            </button>
        {% } %}</span>
    </div>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <div class="tpl-download fade upPhotoContainer">
        <div class="delete textRight">
            <button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
                <i class="icon-trash icon-white"></i>
                <span>{%=locale.fileupload.destroy%}</span>
            </button>
            <input type="checkbox" name="delete" value="1">
        </div></br>
        {% if (file.error) { %}
            <span class="name">
                <span>{%=file.name%}</span>
            </span>
            <span class="error">
                <span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}
            </span>
        {% } else { %}
            <span class="preview">{% if (file.thumbnail_url) { %}
                <a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}" class="lightview"><img src="{%=file.thumbnail_url%}"></a>
            {% } %}</span>
            <span class="name">
                <a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}" class="lightview">{%=file.name%}</a>
            </span>
            <span colspan="2"></span>
        {% } %}
        <div class="photoCaption">
            Caption:</br>
            <textarea name="{%='photoCaption' + i%}"></textarea>
        </div>
        <input type="hidden" name="{%='file' + i%}" value="{%=file.name %}"/>
    </div>
{% } %}
</script>